<template>
  <div class="CustomerManage">
    <div class="search">
      <el-form :inline="true" :model="search" class="demo-form-inline">
        <el-form-item label="输入搜索">
          <el-input
            v-model="search.key"
            placeholder="请输入设备名称"
          ></el-input>
        </el-form-item>
        <el-form-item label="输入时间">
          <el-date-picker
            v-model="search.time"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="chage"
          ></el-date-picker>
        </el-form-item>
        <el-form-item
        >
          <el-button type="primary" @click="onsubmit"
          >查询
          </el-button
          >
        </el-form-item
        >
      </el-form>
      <!-- <el-button class="ebtn" type="warning" @click="GotoPg(null, null)"
        >新增客户</el-button
      > -->
    </div>
    <el-table
      :data="ListData"
      stripe
      style="margin: 10px 20px; width: calc(100% - 40px)"
      :height="autoHeightTable"
      show-overflow-tooltip
    >
      <el-table-column
        label="序号"
        align="center"
      >
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="clientName"
        label="企业名称"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="createTime"
        label="申请时间"
        align="center"
      >
        <template v-slot="scope">
              <span>
                {{ formatTime(scope.row.createTime) }}
              </span>
        </template>
      </el-table-column>
      <el-table-column
        prop="status"
        label="状态"
        align="center"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.status == 1">待发货</span>
          <span v-if="scope.row.status == 2">已发货</span>

        </template>
      </el-table-column>
      <!--<el-table-column prop="expriedebt" label="到期欠款(元)" align="center"></el-table-column>
        <el-table-column prop="unexpriedebt" label="未到期欠款(元)" align="center"></el-table-column>
        <el-table-column prop="totalexpriedebt" label="欠款总额(元)" align="center"></el-table-column>-->
      <el-table-column label="操作" width="300" align="center">
        <template slot-scope="scope">
          <!-- <el-button
            size="small"
            type="warning"
            @click="GotoPg(scope.row.Id, null)"
            >编辑</el-button
          > -->
          <el-button type="text" size="small" @click="getaDD(scope.row.id,scope.row.status)"
          >详情
          </el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next"
      :current-page="current"
      :page-size="pagesize"
      @current-change="handleCurrentChange"
      :page-count="total"
    >
    </el-pagination>
    <!--未发货时-->
    <el-dialog title="发货详情" :visible.sync="dialogVisible_weifahuo" append-to-body  :modal-append-to-body="false">
      <!-- input框 -->
      <div class="conter_box3">
        <template>
          <el-table
            :data="warehouseLogs"
            stripe
            style="width: 100%"
            class="from-fk"
          >
            <el-table-column prop="date" label="序号">
              <template slot-scope="scope">
                <span>{{ scope.$index + 1 }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="productNumber" label="产品图号"></el-table-column>
            <el-table-column prop="productName" label="产品名称"></el-table-column>
            <el-table-column prop="number" label="本次发货数量">
            </el-table-column>
          </el-table>
        </template>
      </div>

      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible_weifahuo = false">返  回</el-button>
      </span>
    </el-dialog>
    <!--已发货时-->
    <el-dialog title="发货详情" :visible.sync="dialogVisible_yifahuo" append-to-body  :modal-append-to-body="false">
      <!-- input框 -->
      <div class="conter_box1" :data="kehuList">
        <ul>
          <li>
            <span>企业名称</span>
            <el-input
              v-model="kehuList.clientName"
              style="width: 70%"
              :disabled="true"
            ></el-input>
          </li>
          <li>
            <span>收货人</span>
            <el-input
              v-model="kehuList.contactPerson"
              style="width: 70%"
              :disabled="true"
            ></el-input>
          </li>
          <li>
            <span>联系方式</span>
            <el-input
              v-model="kehuList.contactPhone"
              style="width: 70%"
              :disabled="true"
            ></el-input>
          </li>
          <li>
            <span>收货地址</span>
            <el-input
              v-model="kehuList.clientAddress"
              style="width: 70%"
              :disabled="true"
            ></el-input>
          </li>
          <li>
            <span>发货日期</span>
            <el-date-picker
              v-model="fahuoList.fahuoTime"
              type="date"
              placeholder="选择日期"
              style="width: 70%"
              value-format="yyyy-MM-dd"
              :disabled="true"
            >
            </el-date-picker>
          </li>
          <li>
            <span>订单编号</span>
            <el-input
              v-model="fahuoList.orderNumber"
              style="width: 70%"
              :disabled="true"
            ></el-input>
          </li>
        </ul>
      </div>
<!--       运输方式 -->
      <div class="conter_box2">
        <p>运输方式</p>

        <!--        <el-radio v-model="xqlist.type" label=1>快递公司</el-radio>-->
        <!--        <el-radio v-model="xqlist.type" label=2>物流公司</el-radio>-->
        <!--</template>  <template>-->
        <!--       -->
        <template>
          <ul v-show="fahuoList.type==1">
            <li>
              <span>快递: 快递公司 :</span>
              <el-input
                v-model="fahuoList.wuliuName"
                readonly
                style="width: 60%"
                :disabled="true"
              ></el-input>
            </li>
            <li>
              <span>快递单号 :</span>
              <el-input
                v-model="fahuoList.wuliuNumber"
                readonly
                style="width: 60%"
                :disabled="true"
              ></el-input>
            </li>
            <li>
              <span>联系人 :</span>
              <el-input
                v-model="kehuList.contactPerson"
                style="width: 60%"
                :disabled="true"
              ></el-input>
            </li>
            <li>
              <span>联系方式 :</span>
              <el-input
                v-model="kehuList.contactPhone"
                style="width: 60%"
                :disabled="true"
              ></el-input>
            </li>
          </ul>
          <ul v-show="fahuoList.type==2">
            <li>
              <span>自送: 司机姓名 :</span>
              <el-input v-model="fahuoList.driver" disabled style="width: 60%"
              />
            </li>
            <li>
              <span>司机联系 :</span>
              <el-input
                v-model="fahuoList.drivarPhone"
                style="width: 60%"
                :disabled="true"
              ></el-input>
            </li>
            <li>
              <span>车牌号 :</span>
              <el-input
                v-model="fahuoList.carNumber"
                style="width: 60%"
                :disabled="true"
              ></el-input>
            </li>
            <li>
              <span>订单编号 :</span>
              <el-input
                v-model="fahuoList.orderNumber"
                style="width: 60%"
                :disabled="true"
              ></el-input>
            </li>
          </ul>
        </template>
      </div>
      <div class="conter_box3">
        <p>货物信息</p>
        <template>
          <el-table
            :data="warehouseLogs"
            stripe
            style="width: 100%"
            class="from-fk"
          >
            <el-table-column prop="date" label="序号">
              <template slot-scope="scope">
                <span>{{ scope.$index + 1 }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="productNumber" label="产品图号"></el-table-column>
            <el-table-column prop="productName" label="产品名称"></el-table-column>
            <el-table-column prop="number" label="本次发货数量">
            </el-table-column>
          </el-table>
        </template>
      </div>

      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible_yifahuo = false">返  回</el-button>

      </span>
    </el-dialog>
  </div>
</template>
<script>
import axios from "axios";

export default {
  data() {
    return {
      radio: "1",
      warehouseLogs: [{}],
      search: {key: "", start: "", end: ""},
      ListData: [{}],
      total: 1,
      current: 1,
      pagesize: 8,
      dialogVisible_weifahuo: false,
      dialogVisible_yifahuo: false,
      options: [],
      Idlist: [],
      kehuList: {
        contactPerson:"",
        clientAddress: "",
        contactPhone: "",
        clientName: "",
      },
      fahuoList:{
        carNumber:"",
        driver:"",
        drivarPhone:"",
        fahuoTime: "",
        wuliuName: "",
        wuliuNumber: "",
        type: 1,
        orderNumber: "",
      },
    };
  },
  computed: {
    autoHeightTable() {
      return document.documentElement.scrollHeight - 251 - 78;
    },
  },
  created() {
    this.getList();
  },
  methods: {

    //时间格式化
    formatTime(data) {
      return data == null ? "" : data.substring(0, 10);
    },
    getList() {
      const json = {
        beginTime: this.search.start,
        endTime: this.search.end,
        key: this.search.key,
        pageNum: this.current,
        pageSize: this.pagesize,
      };
      const message = JSON.parse(localStorage.getItem("message"));
      axios
        .post(
          "/JX_java/sales/fahuoGuanli/getFahuoLog?userId=" + message.Id,
          json
        )
        .then((res) => {
          const relse = res.data.data.content
          this.ListData = relse;
          console.log(this.ListData)
          this.total = res.data.data.totalPages
        });
    },

    getaDD(e, stuats) {
      if (stuats == 1) {
        this.dialogVisible_weifahuo = true
      } else if (stuats == 2) {
        this.dialogVisible_yifahuo = true
      }
      // this.dialogVisible = true,
      // this.getdata(e)
      this.getdata(e, stuats)
    },
    getdata(id, stuats) {
      axios
      (
        "/JX_java/sales/fahuoGuanli/getFahuoLog?id=" + id
      )
        .then((res) => {
          const relse = res.data.data
          if (stuats == 1) {
            this.warehouseLogs = relse.warehouseLogs;
          } else if (stuats == 2) {
            console.log(relse)
            this.fahuoList = relse
            this.kehuList = relse.companyDetails
            this.warehouseLogs = relse.warehouseLogs;
          }
        });
    },
    handleCurrentChange(e) {
      this.current = e;
      this.getList();
    },

    onsubmit() {
      this.getList();
    },

    chage(e) {
      if (e) {
        this.search.start = e[0];
        this.search.end = e[1];
      } else {
        this.search.start = "";
        this.search.end = "";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/assets/scss/base.scss";

.conter_box1 {
  padding: 5px 1% 0 1%;

  ul {
    width: 100%;
    display: flex;
    flex-wrap: wrap;

    li {
      color: #999999;
      width: 33%;
      margin-bottom: 10px;
      text-align: center;

      span {
        display: inline-block;
        width: 25%;
      }
    }
  }
}

.conter_box2 {
  p {
    height: 40px;
    margin-top: 10px;
    // margin-top: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #ebeef5;
  }

  ul {
    width: 100%;
    display: flex;
    flex-wrap: wrap;

    li {
      color: #999999;
      width: 50%;
      margin-bottom: 10px;
      text-align: center;

      span {
        display: inline-block;
        width: 25%;
      }
    }
  }
}

.conter_box3 {
  p {
    height: 40px;
    margin-top: 10px;
    // margin-top: 10px;
    // margin-bottom: 20px;
    border-bottom: 1px solid #ebeef5;
  }

  /deep/ .cell {
    //font-size: 14px !important;
    //color: #999999;
    text-align: center;
    padding: 0;
  }

  /deep/ .el-table th {
    background-color: #fff;
  }
}

.dialog-footer {
  position: absolute;
  right: 15px;
  bottom: 10px;
}

.CustomerManage .search {
  height: 50px;
  border-radius: 5px;
  background-color: #fff;
  padding-left: 20px;
  padding-top: 10px;
  margin: 0 20px;
}

.CustomerManage .demo-form-inline {
  display: inline-block;
}

.CustomerManage .el-pagination {
  margin-top: 15px;
  text-align: center;
}

.CustomerManage .ebtn {
  float: right;
  margin-right: 20px;
}
</style>
